//
//  HTStats.swift
//  weibo
//
//  Created by JonsonLiu on 16/4/21.
//  Copyright © 2016年 liujonson. All rights reserved.
//

import UIKit

class HTStats: NSObject {

    
    //下拉刷新ID
    var id : Int64 = 0
    /// 当前微博的内容
    var text: String?
    /// 微博的创建时间
    var created_at: String?
    /// 来源
    var source: String?
    /// 当前微博的用户信息
    var user: HTUser?
    
    var retweeted_status: HTStats?
    //配图数组
    var pic_urls : [HTStatusPhotoInfo]?
    

 
    // 添加字典转模型的构造函数
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    
    
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
        
            guard let dict = value as? [String : AnyObject] else {
            
                return
            }
        
            user = HTUser(dict: dict)
        }else if key == "retweeted_status" {
        
            guard let dict = value as? [String: AnyObject] else {
                return
            }
            retweeted_status = HTStats(dict: dict)
            return
            
        }else if key == "pic_urls" {
            
            guard let dict = value as? [[String : AnyObject]] else{
                return
            }
            var tempArray = [HTStatusPhotoInfo]()
            for dicts in dict{
                let  info = HTStatusPhotoInfo(dict : dicts)
                tempArray.append(info)
            }
            pic_urls = tempArray
        }else{
        
            super.setValue(value, forKey: key)
        }
    }
    
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
}
